//
//  HomeBottomView.m
//  YiXiProject
//
//  Created by iMac on 2019/7/12.
//  Copyright © 2019 iMac. All rights reserved.
//

#import "HomeBottomView.h"

@implementation HomeBottomView

-(UIButton *)renovateButton
{
    if(!_renovateButton)
    {
        _renovateButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _renovateButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _renovateButton.layer.masksToBounds = YES;
        [_renovateButton setImage:[UIImage imageNamed:@"firstImg"] forState:UIControlStateNormal];
        _renovateButton.tag = 100;
        _renovateButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _renovateButton.layer.masksToBounds = YES;
        _renovateButton.backgroundColor = ColorAlphe(245, 245, 245, 1);
        [_renovateButton addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _renovateButton;
}

-(UIButton *)dislikeButton
{
    if(!_dislikeButton)
    {
        _dislikeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _dislikeButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _dislikeButton.layer.masksToBounds = YES;
        [_dislikeButton setImage:[UIImage imageNamed:@"twoImg"] forState:UIControlStateNormal];
        _dislikeButton.tag = 101;
        _dislikeButton.layer.cornerRadius = (SCREEN_WIDTH/5-20)/2;
        _dislikeButton.layer.masksToBounds = YES;
        _dislikeButton.backgroundColor = ColorAlphe(245, 245, 245, 1);
        [_dislikeButton addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _dislikeButton;
}

-(UIButton *)collectButton
{
    if(!_collectButton)
    {
        _collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _collectButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _collectButton.layer.masksToBounds = YES;
        [_collectButton setImage:[UIImage imageNamed:@"threeImg"] forState:UIControlStateNormal];
        _collectButton.tag = 102;
        _collectButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _collectButton.layer.masksToBounds = YES;
        _collectButton.backgroundColor = ColorAlphe(245, 245, 245, 1);
        [_collectButton addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _collectButton;
}

-(UIButton *)likeButton
{
    if(!_likeButton)
    {
        _likeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _likeButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _likeButton.layer.masksToBounds = YES;
        [_likeButton setImage:[UIImage imageNamed:@"fourImg"] forState:UIControlStateNormal];
        _likeButton.tag = 103;
        _likeButton.layer.cornerRadius = (SCREEN_WIDTH/5-20)/2;
        _likeButton.layer.masksToBounds = YES;
        _likeButton.backgroundColor = ColorAlphe(245, 245, 245, 1);
        [_likeButton addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _likeButton;
}

-(UIButton *)lightningButton
{
    if(!_lightningButton)
    {
        _lightningButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _lightningButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _lightningButton.layer.masksToBounds = YES;
        [_lightningButton setImage:[UIImage imageNamed:@"fiveImg"] forState:UIControlStateNormal];
        _lightningButton.tag = 104;
        _lightningButton.layer.cornerRadius = (SCREEN_WIDTH/5-40)/2;
        _lightningButton.layer.masksToBounds = YES;
        _lightningButton.backgroundColor = ColorAlphe(245, 245, 245, 1);
        [_lightningButton addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _lightningButton;
}


-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self addSubview:self.renovateButton];
        [self addSubview:self.dislikeButton];
        [self addSubview:self.collectButton];
        [self addSubview:self.likeButton];
        [self addSubview:self.lightningButton];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
//    _renovateButton.sd_layout.leftSpaceToView(self, 20).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
//    _dislikeButton.sd_layout.leftSpaceToView(_renovateButton, 30).topSpaceToView(self, 10).widthIs(SCREEN_WIDTH/5-20).heightIs(SCREEN_WIDTH/5-20);
//    _collectButton.sd_layout.leftSpaceToView(_dislikeButton, 30).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
//    _likeButton.sd_layout.leftSpaceToView(_collectButton, 30).topSpaceToView(self, 10).widthIs(SCREEN_WIDTH/5-20).heightIs(SCREEN_WIDTH/5-20);
//    _lightningButton.sd_layout.leftSpaceToView(_likeButton, 30).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
    
    _renovateButton.sd_layout.leftSpaceToView(self, 20).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
    
    _dislikeButton.sd_layout.leftSpaceToView(_renovateButton, 30).topSpaceToView(self, 10).widthIs(SCREEN_WIDTH/5-20).heightIs(SCREEN_WIDTH/5-20);
    
    _collectButton.sd_layout.leftSpaceToView(self, SCREEN_WIDTH/2-(SCREEN_WIDTH/5-40)/2).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
    
    _lightningButton.sd_layout.rightSpaceToView(self, 20).topSpaceToView(self, 20).widthIs(SCREEN_WIDTH/5-40).heightIs(SCREEN_WIDTH/5-40);
    
    _likeButton.sd_layout.rightSpaceToView(_lightningButton, 30).topSpaceToView(self, 10).widthIs(SCREEN_WIDTH/5-20).heightIs(SCREEN_WIDTH/5-20);
}

-(void)clickBtn:(UIButton *)butt
{
    if([_delegate respondsToSelector:@selector(clickTagNum:)])
    {
        [_delegate clickTagNum:butt];
    }
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
